<?php
namespace app\api\controller;
use think\Controller;
use think\Request;
use think\Config;

class Live
{
    public function index()
    {
    	//直播员数据入库
    	//直播员数据推送到直播页面
    	$data = $_POST;

        $pushData = [
            'type'=> $data['type'] == 1 ? '第一节':($data['type'] == 2 ? '第二节':($data['type'] == 3?'第三节':'第四节')),
            'title'=> $data['team_id'] == 1 ? '马刺':($data['team_id'] == 4 ? '火箭' : '解说员'),
            'logo'=> $data['team_id'] == 1 ? '/live/imgs/team1.png':($data['team_id'] == 4? '/live/imgs/team2.png':''),
            'content'=> !empty($data['content']) ? $data['content'] : '',
            'image'=>!empty($data['image'])?$data['image']:''
        ];

        //异步任务
        $_POST['swoole_ws']->task(['method'=>'pushDataToLive','data'=>$pushData]);

        return json_encode($pushData);
	    
    }
}
